cmake_minimum_required(VERSION 3.0)

project(lightning)

set(CMAKE_VERBOSE_MAKEFILE ON) #显示编码详细详细

#set(cmake/utils.cmake)

#添加自定义的编译命令
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -rdynamic -O0 -ggdb -std=c++11 -Wall -Wno-deprecated -Werror -Wno-unused-function")

#添加要编译的文件
set(LIB_SRC
    source/log.cpp
    source/util.cpp
    source/config.cpp
    source/thread.cpp
    source/mutex.cpp
    source/fiber.cpp
    source/scheduler.cpp
    source/IOmanager.cpp
    source/timer.cpp
    source/hook.cpp
    source/fd_manager.cpp
    source/address.cpp
    source/socket.cpp
    source/byte_array.cpp
    source/http/http.cpp
    source/http/http11_parser.cpp         #.rl 生成文件
    source/http/httpclient_parser.cpp     #.rl 生成文件
    source/http/http_parser.cpp
    source/tcp_server.cpp
    source/stream.cpp
    source/streams/socket_stream.cpp
    source/http/http_session.cpp
    source/http/http_server.cpp
    source/http/servlet.cpp
    source/http/http_connection.cpp
    source/uri.cpp                        #.rl 生成文件               
    # tests/testHttpServer.cpp #调试程序使用
    )

#添加库头文件目录
link_directories(/usr/lib)


#生成静态库
add_library(lightning SHARED ${LIB_SRC})
#force_redefine_file_macro_for_sources(lightning) #重定义相对路径

#include_directories(source)
#link_directories(lib)

set(LIBLIB
    lightning
    pthread
    libyaml-cpp.a
    dl  #使用dlsym函数
    )




#生成测试文件==============================================================
#add_executable(testLog tests/testLog.cpp)

#add_executable(testConfig tests/testConfig.cpp)
#add_executable(testConfig ${LIB_SRC})  #调试程序使用
#force_redefine_file_macro_for_sources(testConfig) #重定义相对路径

#add_executable(testThread tests/testThread.cpp)
#add_executable(testUtil tests/testUtil.cpp)
# add_executable(testFiber tests/testFiber.cpp)
# add_executable(testScheduler tests/testScheduler.cpp)
# add_executable(testIOmanager tests/testIOmanager.cpp)
# add_executable(testHook tests/testHook.cpp)
# add_executable(testAddrs tests/testAddress.cpp)
# add_executable(testSocket tests/testSocket.cpp)
# add_executable(testByteArray tests/testByteArray.cpp)
# add_executable(testHttp tests/testHttp.cpp)
# add_executable(testHttpParser tests/testHttpParser.cpp)
# add_executable(testTCPServer tests/testTCPServer.cpp)
# add_executable(testHttpServer tests/testHttpServer.cpp)
add_executable(testHttpConnection tests/testHttpConnection.cpp)
add_executable(testUri tests/testUri.cpp)

#调试程序使用
# add_executable(testHttpServer ${LIB_SRC})

#添加链接库
#target_link_libraries(testConfig ${LIBLIB})
#target_link_libraries(testThread ${LIBLIB})  
# target_link_libraries(testUtil ${LIBLIB})  
# target_link_libraries(testFiber ${LIBLIB}) 
# target_link_libraries(testScheduler ${LIBLIB}) 
# target_link_libraries(testIOmanager ${LIBLIB}) 
# target_link_libraries(testHook ${LIBLIB}) 
# target_link_libraries(testAddrs ${LIBLIB}) 
# target_link_libraries(testSocket ${LIBLIB}) 
# target_link_libraries(testByteArray ${LIBLIB}) 
# target_link_libraries(testHttp ${LIBLIB})
# target_link_libraries(testHttpParser ${LIBLIB})
# target_link_libraries(testTCPServer ${LIBLIB})
# target_link_libraries(testHttpServer ${LIBLIB})
target_link_libraries(testHttpConnection ${LIBLIB})
target_link_libraries(testUri ${LIBLIB})

#生成测试文件==============================================================




#生成示例文件==============================================================
# add_executable(test_echo_server examples/echo_server.cpp)
# target_link_libraries(test_echo_server ${LIBLIB})
#生成示例文件==============================================================




#设置程序和库的路径
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
